package com.wy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wy.entity.GoodsImage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface GoodsImageMapper extends BaseMapper<GoodsImage> {


    /**
     * 批量插入 商品id 和图片名称
     * @param images 图片名称
     * @param goodsId 商品id
     * @return
     */
    @Insert("<script>" +
            "INSERT INTO goods_image" +
            "        (image,goods_id)" +
            "        VALUES" +
            "        <foreach collection ='images' item='image' separator =','>" +
            "            (#{image},#{goodsId})" +
            "        </foreach >" +
            "</script>" )
    int insertBatch(List<String> images,Long goodsId);



    /**
     *
     * @param images 图片名称
     * @param evaluationId  评论id
     * @return
     */
    @Insert("<script>" +
            "INSERT INTO goods_image" +
            "        (image,evaluation_id)" +
            "        VALUES" +
            "        <foreach collection ='images' item='image' separator =','>" +
            "            (#{image},#{evaluationId})" +
            "        </foreach >" +
            "</script>" )
    int insertBatchEvaluation(List<String> images,Long evaluationId);


}